<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller {
	

	public function __construct()
    {
		header('Content-Type:text/html; charset=utf-8');
        parent::__construct();	
		$this->load->helper('url');
		$this->load->library('session');
		if(!$this->session->userdata("user")){				
			header('Location: /index.php/login');
		}
		// $this->checkRbac();
	}	
	
	private function checkRbac(){
		$className = $this->uri->segment(1);
		$methodName = $this->uri->segment(2);
		
		$className = $className ? $className : 'welcome';
		$methodName = $methodName ? $methodName : 'index';
		
		if(!in_array($className . $methodName, $this->session->userdata('userpower'))){
			echo '<script>alert("抱歉，您无此操作权限！");window.history.back()</script>';
			exit();
		}
	}
	
	public function getMenu(){
		return file_get_contents('./application/cache/' . $this->session->userdata('userid') . '.txt');
	}
	
}
